﻿using BasicInformation.ApiRead.Application.Command.Location;
using BasicInformation.Domain;
using BasicInformation.Dtos;
using BasicInformation.ErrorCode;
using BasicInformation.Infrastructure.Interface;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.ApiRead.Controllers
{
    /// <summary>
    /// 库位管理控制器——读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class LocationController : ControllerBase
    {
        private readonly IMediator mediator;

        public LocationController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 库位管理显示分页查询接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<LocationDTO>> GetLocation([FromQuery]GetLocationCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 库位类型管理显示接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
       [HttpGet]
        public Task<ApiPaging<LocationTypeModel>> GetLocationType([FromQuery]GetLocationTypeCommand request)
        {
            return mediator.Send(request);
        }
    }
}
